program q121;
var
    n, i, ans, last, t, dis: integer;
begin
    assign(input, '');
    assign(output, '');
    reset(input);
    rewrite(output);

    while (not seekeof) do
    begin
        read(n);
        if (n = 0) then break;

        ans := 0;
        last := 0;
        for i:=1 to n do
        begin
            read(t);

            dis := last - t;
            if (dis >= 0) then
                ans := ans + dis * 4
            else
                ans := ans + abs(dis) * 6;
            last := t;
        end;
        ans := ans + n * 5;

        writeln(ans);
    end;

    close(input);
    close(output);
end.
